<template>
	<view class="p24">
		<view class="w-max pr radius20 ov-h mb20">
			<view class="background wh-max radius20 pa left0 top0 wh-max">
				<image src="/static/img/my/balance_bg.png" class="wh-max" mode=""></image>
			</view>
			<view class="pr p20 color-fff">
				<view class="fs30 fw-600">实名认证成功后即可开启陪诊板块接单</view>
				<view class="fs26 mt10 opa9">请填写真实信息以便审核，我们将严格保密。</view>
			</view>
		</view>

		<u-form :model="form" ref="uForm" labelWidth="auto" :clearable="false" :borderBottom="false" inputAlign="right">
			<view class="fs30 tit-ac mb22">请上传本人真实照片</view>
			<view class="p24 bg-fff radius12 mb22">
				<z-imgs up @success="form.photo=$event" :ids="data.photo" :paths="data.photo_path" />
			</view>

			<view class="fs30 tit-ac mb22">请上传身份证</view>
			<view class="p24 bg-fff radius12 mb22">
				<view class="mb22 flex col-top">
					<view class="">身份证头像面</view>
					<view class="flex row-center flex1">
						<z-imgs up @success="form.id_front=$event" width="358" height="270"
							upSrcImg="/static/img/my/user/sf1.png" :ids="data.id_front" :paths="data.id_front_path" />
					</view>
				</view>
				<view class="mb22 flex col-top">
					<view class="">身份证国徽面</view>
					<view class="flex row-center flex1">
						<z-imgs up @success="form.id_back=$event" width="358" height="270" :ids="data.id_back"
							:paths="data.id_back_path" upSrcImg="/static/img/my/user/sf2.png" />
					</view>
				</view>
			</view>
			<view class="fs30 tit-ac mb22">请填写本人身份信息</view>
			<view class="pl20 pr20  bg-fff radius12 mb22">
				<u-form-item label="真实姓名" prop="name">
					<u-input v-model="form.real_name" placeholder="请输入真实姓名" />
				</u-form-item>
			</view>
			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="身份证号" prop="id_card">
					<u-input v-model="form.id_card" type="idcard" maxlength="18" placeholder="请输入身份证号" />
				</u-form-item>
			</view>
			<view class="fs30 tit-ac mb22">请填写个人资料</view>
			<view class="pl20 pr20 bg-fff radius12 mb22 ">
				<u-form-item label="联系电话" prop="mobile">
					<u-input v-model="form.mobile" type="number" maxlength="11" placeholder="请输入手机号码" />
				</u-form-item>
			</view>
			<auto-select ref="sex" :list="sexList" @confirm="form.sex=$event[0].value" title="请选择性别" />
			<view class="pl20 pr20 bg-fff radius12 mb22 ">
				<u-form-item label="性别" prop="sex">
					<u-input :modelValue="$list('sex',form.sex)" type="select" @click="$refs.sex.open()"
						placeholder="请选择性别" />
				</u-form-item>
			</view>

			<view class="pl20 pr20 bg-fff radius12 mb22 ">
				<u-form-item label="服务地区" prop="sex" rightIcon="arrow-right">
					<u-input v-model="form.city_name" @click="setAdd" placeholder="请选择服务地区" disabled />
				</u-form-item>
			</view>

			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="服务医院" rightIcon="arrow-right">
					<u-input :modelValue="form.hospital_ids?'已选择':''" @click="$refs.hospital.open()" disabled
						placeholder="请选择(可多选)" />
				</u-form-item>
			</view>

			<select-list ref="hospital" title="请选择服务医院(可多选)" api="master/commom/getHospital"
				:apiParams="{city_id:form.city_id,type:'name'}" labelName="name" valueName="id"
				@confirm="form.hospital_ids=$event.join()" :checked="form.hospital_ids"></select-list>


			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="常驻地址" prop="address">
					<u-input v-model="form.address" placeholder="请输入常驻地址" />
				</u-form-item>
			</view>


			<view class="pl20 pr20  bg-fff radius12 mb22 ">
				<u-form-item label="最早从业时间" rightIcon="arrow-right">
					<u-input v-model="form.start_work_time" disabled @click="timeShow=true" placeholder="请选择时间" />
				</u-form-item>
			</view>
			<u-picker v-model="timeShow" mode="time" @confirm="setTime"></u-picker>

			<view class="fs30 tit-ac mb22">
				<text>请上传资格证书</text>
			</view>
			<view class="p24 bg-fff radius12 mb22">
				<z-imgs up max="2" @success="form.credentials=$event" :ids="data.credentials"
					:paths="data.credentials_path" />
			</view>
			<view class="fs30 tit-ac mb22 flex ">
				<view class="flex1">请上传体检报告</view>
				<view class="color-red">*</view>
				<view class="fs24 color-999">请上传近3个月的体检报告</view>
			</view>
			<view class="p24 bg-fff radius12 mb22">
				<z-imgs up max="1" @success="form.report=$event" :ids="data.report" :paths="data.report_path" />
			</view>

			<view class="h120"></view>
			<view class="pf bottom0 left0  w-max flex z-index1">
				<view class="p24 flex1">
					<u-button type="warning" ripple @click="submit">{{data.status_text||'立即认证'}}</u-button>
				</view>
			</view>
		</u-form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				timeShow: false,
				form: {
					photo: "", //	整型	必填	-	-	本人照片
					id_front: "", //	整型	必填	-	-	身份证正面
					id_back: "", //	整型	必填	-	-	身份证反面
					real_name: "", //	字符串	必填	-	-	真实姓名
					id_card: "", //	字符串	必填	-	-	身份证号
					sex: "", //	整型	必填	-	-	性别：1男，2女
					mobile: "", //	字符串	必填	-	-	手机号
					city_id: "", //	整型	必填	-	-	城市id
					city_name: "", //	整型	必填	-	-	城市id
					hospital_ids: "", //	字符串	必填	-	-	医院id（,号隔开）
					address: "", //	字符串	必填	-	-	常住地址
					start_work_time: "", //	字符串	必填	-	-	开始工作时间2023-3-13
					credentials: "", //	整型	必填	-	-	资格证书
					report: "", //	整型	必填	-	-	体检报告
				},

				sexList: [{
						label: '男',
						value: '1'
					},
					{
						label: '女',
						value: '2'
					},
				],
				data: ''
			}
		},
		onReady() {},
		onLoad() {
			let city = this.$store.city || ''
			this.form.city_id = city.id || ''
			this.form.city_name = city.name || ''

			// let autonym = this.$getData('autonym')
			// Object.keys(autonym).map(key=>{
			// 	this.form[key]=autonym[key]??this.form[key]
			// })
			this.getData()
		},
		methods: {
			getData() {
				this.$request('/master/personal/nameInfo').then(res => {
					this.data = res.data || ""
					if (res.data) {
						Object.keys(this.form).map(key => {
							this.form[key] = res.data[key] || this.form[key]
						})
					}
				})
			},
			submit() {
				console.log(this.form)
				// this.$setData('autonym', this.form)
				this.$request('/master/personal/nameAuth', this.form).then(res => {
					this.$msg(res.msg)
					setTimeout(this.$navBack, 1000)
				})
			},
			setTime(e) { //设置时间
				let value = ''
				if (e.year) value += e.year
				if (e.month) value += '-' + e.month
				if (e.day) value += '-' + e.day
				if (e.hour) value += ' ' + e.hour
				if (e.minute) value += ':' + e.minute
				this.form.start_work_time = value
			},
			setAdd() { //设置城市
				uni.$once('set_city_id', city => {
					this.form.city_id = city.id
					this.form.city_name = city.name

					this.form.hospital_ids = ''
					if (this.$refs.hospital?.selectList) {
						this.$refs.hospital.selectList = ''
					}
				})
				this.$jump('/pages/index/chooseAddress', {
					set: 'set_city_id'
				})
			},
		}
	}
</script>

<style lang="scss">

</style>